/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.googlecode.jmicroerp.model;

import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
 *
 * @author Alexandru.Codescu
 */
@Entity
@Table(name = "recipient")

@NamedQueries({
    @NamedQuery(
        name = "Recipient.queryButoaie",
        query = "select rec.denumire, mag.denumire, tr.denumire, tr.capacitate, "
        		+ "sto.cantitate, sto.produs.pret, sto.produs.caleImagine, rec.id, mag.id, sto.produs.id "
	            + "from Recipient rec "
	            + "join rec.tipRecipient tr "
	            + "join rec.magazin mag "
	            + "join rec.stoc sto "
	            + "where tr.categorie = 1 and mag.id = ?1"),
     @NamedQuery(
        name = "Recipient.listDenumiri",
        query = "select rec.id, rec.denumire "
                + "from Recipient rec "
                + "join rec.magazin mag "
                + "where rec.denumire = ?1 and mag.id = ?2")            
})

public class Recipient extends AbstractEntitate {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private NTipRecipient tipRecipient;
    private Magazin magazin;
    private String denumire;
    private Stoc stoc;
    private BigDecimal ordine;
    private Boolean activ;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "TIP_RECIPIENT_ID")
    public NTipRecipient getTipRecipient() {
        return tipRecipient;
    }

    public void setTipRecipient(NTipRecipient tipRecipient) {
        this.tipRecipient = tipRecipient;
    }

    @Column(name = "DENUMIRE", length = 50)
    public String getDenumire() {
        return denumire;
    }

    public void setDenumire(String denumire) {
        this.denumire = denumire;
    }

    @OneToOne(fetch = FetchType.LAZY, mappedBy = "recipient")
    public Stoc getStoc() {
        return stoc;
    }

    public void setStoc(Stoc stoc) {
        this.stoc = stoc;
    }

    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Magazin.class)
    @JoinColumn(name = "MAGAZIN_ID")    
    public Magazin getMagazin() {
        return magazin;
    }

    public void setMagazin(Magazin magazin) {
        this.magazin = magazin;
    }
    
    @Column(name = "ORDINE")
    public BigDecimal getOrdine() {
        return ordine;
    }

    public void setOrdine(BigDecimal ordine) {
        this.ordine = ordine;
    }
    
    @Column(name = "ACTIV")
    public Boolean isActiv() {
        return activ;
    }

    public void setActiv(Boolean activ) {
        this.activ = activ;
    }   
    
}
